A Python-based web service that fetches movie scripts from various online sources including IMSDB and Cinematheque.fr.
git clone https://github.com/yourusername/script-scraper.git
cd script-scraper
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e .
Run the server with:
python src/main.py
The server will start on http://localhost:8000. You can access the interactive API documentation at http://localhost:8000/docs.
GET /scripts/search?title={movie_title}
Example response:
{
"title": "The Matrix",
"url": "https://imsdb.com/scripts/Matrix.html",
"source": "IMSDB"
}
GET /scripts/{movie_title}
Example response:
{
"title": "The Matrix",
"script": "INT. COMPUTER SCREEN\nText flowing in tight corridors...",
"source": "IMSDB",
"url": "https://imsdb.com/scripts/Matrix.html"
}
GET /scripts/{movie_title}/bechdel
Example response:
{
"passes_test": true,
"female_characters": [
{
"name": "Trinity",
"gender": "female",
"lines": [
"The answer is out there, Neo.",
"It's looking for you."
]
}
],
"conversations": [
{
"participants": ["Trinity", "Switch"],
"dialogue": [
"Is everything in place?",
"Yes. They don't know we're monitoring."
],
"about_men": false,
"context": "Opening scene"
}
],
"failure_reasons": null
}
This endpoint analyzes a movie script using the Bechdel test criteria:
The response includes:
The API uses standard HTTP status codes:
200: Success404: Script not found503: Scraping error (e.g., source website down)Error response example:
{
"error": "Script scraping failed",
"details": "Connection timeout"
}
Run the test suite with:
pytest
src/
├── api/
│ ├── models.py # Pydantic models
│ └── server.py # FastAPI server
├── core/
│ └── scrapers/
│ ├── base.py # Base scraper interface
│ ├── imsdb.py # IMSDB implementation
│ └── cinematheque.py # Cinematheque implementation
└── main.py # Entry point
tests/
├── test_api.py # API tests
└── test_scrapers.py # Scraper tests
git checkout -b feature/amazing-feature)git commit -m 'feat: add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.